<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class SubjectRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|min:2|unique:subjects,name', //unique参数 第一个哪个表 第二个 哪个字段名
        ];
    }

    public function messages()
    {
        return [
            'name.required' => '科目名是必填的',
            'name.min'      => '科目名至少2个字符',
            'name.unique'   => '科目名不能重复',
        ];
    }
}
